﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Microsoft.Practices.Unity;
using VLUSM_BusinessLogic;
using System.Collections.ObjectModel;
using VLUSM_BusinessLogic.DataTransferObjects;

namespace VLUSM_Service
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "SystemService" in code, svc and config file together.
    public class SystemService : ISystemService
    {
        IUnityContainer container;
        SystemManager manager;

        public SystemService()
        {
            container = new UnityContainer();
            manager = container.Resolve<SystemManager>();
        }


        public ObservableCollection<DonViDTO> GetDonViList()
        {
            return manager.GetDonViList();
        }

        #region User Methods
        public ObservableCollection<UserDTO> GetUserList()
        {
            return manager.GetUserList();
        }

        public ObservableCollection<UserDTO> GetUserByDonViID(int DonViIDFilter)
        {
            return manager.GetUserByDonViID(DonViIDFilter);
        }

        public UserDTO GetUserByID(int IDFilter)
        {
            return manager.GetUserByID(IDFilter);
        }

        public UserDTO GetUserByTenTaiKhoan(string TenTaiKhoanFilter)
        {
            return manager.GetUserByTenTaiKhoan(TenTaiKhoanFilter);
        }

        public void SaveUser(UserDTO objdto)
        {
            manager.SaveUser(objdto);
        }

        public void SaveUserWithDonViList(UserDTO objdto, ObservableCollection<DonViDTO> listdto)
        {
            manager.SaveUserWithDonViList(objdto, listdto);
        }

        public void SaveDonViWithQuyenList(DonViDTO objdto, ObservableCollection<QuyenDTO> listdto)
        {
            manager.SaveDonViWithQuyenList(objdto, listdto);
        }

        public ObservableCollection<DonViDTO> GetDonViNotYetByUserID(int UserID)
        {
            return manager.GetDonViNotYetByUserID(UserID);
        }

        public ObservableCollection<DonViDTO> GetDonViByUserID(int UserID)
        {
            return manager.GetDonViByUserID(UserID);
        }

        public void SetDonViListForUser(int UserID, ObservableCollection<DonViDTO> listDTO)
        {
            manager.SetDonViListForUser(UserID, listDTO);
        }

        public void UnSetDonViListForUser(int UserID, ObservableCollection<DonViDTO> listDTO)
        {
            manager.UnSetDonViListForUser(UserID, listDTO);
        }

        public void RemoveUser(UserDTO objdto)
        {
            manager.RemoveUser(objdto);
        }

        public void RemoveUserByID(int IDFilter)
        {
            manager.RemoveUserByID(IDFilter);
        }

        public void AssignUserToDonVi(int UserID, int DonViID)
        {
            manager.AssignUserToDonVi(UserID, DonViID);
        }

        public void AssignUserListToDonVi(ObservableCollection<UserDTO> dtoList, int DonViID)
        {
            manager.AssignUserListToDonVi(dtoList, DonViID);
        }
        #endregion

        #region Quyen Methods
        public ObservableCollection<QuyenDTO> GetQuyenList()
        {
            return manager.GetQuyenList();
        }

        public ObservableCollection<QuyenDTO> GetQuyenByDonViID(int DonViIDFilter)
        {
            return manager.GetQuyenByDonViID(DonViIDFilter);
        }

        public ObservableCollection<QuyenDTO> GetQuyenNotYetByDonViID(int DonViIDFilter)
        {
            return manager.GetQuyenNotYetByDonViID(DonViIDFilter);
        }

        public void SetQuyenForDonVi(int DonViID, int QuyenID)
        {
            manager.SetQuyenForDonVi(DonViID, QuyenID);
        }

        public void SetQuyenListForDonVi(int DonViID, ObservableCollection<QuyenDTO> listDTO)
        {
            manager.SetQuyenListForDonVi(DonViID, listDTO);
        }

        public void UnSetQuyenListForDonVi(int DonViID, ObservableCollection<QuyenDTO> listDTO)
        {
            manager.UnSetQuyenListForDonVi(DonViID, listDTO);
        }
        #endregion
    }
}
